(function (isUndefined) { var win = window; var Util = win.EB.util; Handlebars.registerHelper("Currency", function (str) { var _Currency = Util.getCurrency(str); return _Currency == "NaN" ? "" : _Currency; }); Handlebars.registerHelper("Percent", function (str) { return str + "%"; }); Handlebars.registerHelper("BuildImgUrl", function (path) { var r = null; if (path != isUndefined) { var s0 = path[0]; var _imgDomain = "//item.elandrs.com/upload"; var _path = path; if (s0 == "r") { _imgDomain = win.hasOwnProperty("UIPage") && win.UIPage.hasOwnProperty("itemUrl") ? win.UIPage.itemUrl + "/" : "//item.elandrs.com/"; } else { if (s0 != "/") { _imgDomain = _imgDomain + "/"; } } r = _imgDomain + _path; } return r; }); Handlebars.registerHelper("Consoler", function (every) { console.log(every); return every; }); // https://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional Handlebars.registerHelper("x", function (expression, options) { var result; // you can change the context, or merge it with options.data, options.hash var context = this; // yup, i use 'with' here to expose the context's properties as block variables // you don't need to do {{x 'this.age + 2'}} // but you can also do {{x 'age + 2'}} // HOWEVER including an UNINITIALIZED var in a expression will return undefined as the result. with (context) { result = function () { try { return eval(expression); } catch (e) { console.warn("•Expression: {{x '" + expression + "'}}\n•JS-Error: ", e, "\n•Context: ", context); } }.call(context); // to make eval's lexical this=context } return result; }); Handlebars.registerHelper("xif", function (expression, options) { return Handlebars.helpers["x"].apply(this, [expression, options]) ? options.fn(this) : options.inverse(this); }); })();